package com.appsys.controller;

import com.appsys.pojo.Msg;
import com.appsys.pojo.SecondLevel;
import com.appsys.pojo.ThirdLevel;
import com.appsys.service.FirstLevelService;
import com.appsys.service.SecondLevelService;
import com.appsys.service.ThirdLevelService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName SelectController
 * @Description TODO
 * @Author YinLiangTao Email:1517535831@qq.com
 * @Date 2022/2/28 17:10
 * @Version 1.0
 */
@Controller
public class SelectController {
    @Resource
    private FirstLevelService firstLevelService;
    @Resource
    private SecondLevelService secondLevelService;
    @Resource
    private ThirdLevelService thirdLevelService;

    @RequestMapping(value = "/secondLevel/{fid}")
    @ResponseBody
    public Msg getSecondLevel(@PathVariable(value = "fid") int fid){
        List<SecondLevel> secondLevels = secondLevelService.getSecondLevels(fid);
        return Msg.success().add("secondLevels",secondLevels);
    }
    @RequestMapping(value = "/thirdLevel/{sid}")
    @ResponseBody
    public Msg getThirdLevel(@PathVariable(value = "sid") int sid){
        List<ThirdLevel> thirdLevels = thirdLevelService.getThirdLevels(sid);
        return Msg.success().add("thirdLevels",thirdLevels);
    }
}
